package com.iias.communication.packet;


import com.iias.communication.util.ByteUtils;
import com.iias.communication.util.IntegerToByte;
import com.iias.communication.util.LongToByte;

/**
 * 包头
 */
public class PacketHeard {
    /**
     * 序列ID 4个长度
     */
    private int seqId;
    /**
     * 业务ID 4个长度
     */
    private int msgId;

    /**
     * 时间  YYYYMMDDHHMMSSsss 8个长度
     */
    private long time;

    /**
     * 版本号 4个长度
     */
    private int version;
    /**
     * 包体长度 8个长度
     */
    private long length;



    public byte[] stringEncoding(){
        byte[] seqIdByte = IntegerToByte.integerTo4Bytes(seqId);
        byte[] msgIdByte = IntegerToByte.integerTo4Bytes(msgId);
        byte[] timeByte = LongToByte.longToBytes(time, 8);
        byte[] versionByte = IntegerToByte.integerTo4Bytes(version);
        byte[] lengthByte = LongToByte.longToBytes(length, 8);
        return ByteUtils.concat(seqIdByte,msgIdByte,timeByte,versionByte,lengthByte);
    }

    public int getSeqId() {
        return seqId;
    }

    public void setSeqId(int seqId) {
        this.seqId = seqId;
    }

    public int getMsgId() {
        return msgId;
    }

    public void setMsgId(int msgId) {
        this.msgId = msgId;
    }

    public long getTime() {
        return time;
    }

    public void setTime(long time) {
        this.time = time;
    }

    public int getVersion() {
        return version;
    }

    public void setVersion(int version) {
        this.version = version;
    }

    public long getLength() {
        return length;
    }

    public void setLength(long length) {
        this.length = length;
    }
}
